package com.glsc.ngateway.common.base.repo.mysql.gateway.platform.flow.cmdb;


import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.flow.cmdb.FlowFormDeviceIn;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zhengyr
 */
@Repository
public interface FlowFormDeviceInRepo extends JpaRepository<FlowFormDeviceIn, Long>, JpaSpecificationExecutor<FlowFormDeviceIn> {
    /**
     * 根据流程Id检索表单
     */
    FlowFormDeviceIn findByProcessId(String processId);
    List<FlowFormDeviceIn> findAllByProcessId(String processId);

    @Query(value = "select distinct i.* from t_gw_flow_form_device_in_detail d" +
            " left join t_gw_flow_form_device_in i on d.process_id = i.process_id  where i.is_close = 0 and d.sn = :sn  ", nativeQuery = true)
    List<FlowFormDeviceIn> findFlowSn(String sn);
}
